class Solution:
    def findAnagrams(self, s: str, p: str) -> List[int]:
        mapper={}
        result=[]
        for i in p:
            try:
                mapper[i]+=1
            except KeyError:
                mapper[i]=1
        judger={}
        if len(s)<len(p):
            return []
        for i in range(len(p)):
            try:
                judger[s[i]]+=1
            except KeyError:
                judger[s[i]]=1
        if judger==mapper:
            result.append(0)
        for i in range(1,len(s)-len(p)+1):
            judger[s[i-1]]-=1
            if judger[s[i-1]]==0:
                del judger[s[i-1]]
            try:
                judger[s[i+len(p)-1]]+=1
            except KeyError:
                judger[s[i+len(p)-1]]=1
            if judger==mapper:
                result.append(i)
        return result


'''
执行用时: 136 ms
内存消耗: 14.5 MB

'''